Full source code website bán hàng thương mại điện tử gần giống shopee
468.895 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Nhà cung cấp : <b> <a href="./?act=provider_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> |</font></b></td>
6 </tr>
7 </table>
8 <?
9 $MAXPAGE=20;
10
11 switch ($_GET['action'])
12 {
13 case 'del' :
14 $id = $_GET['id'];
15 $result = mysql_query("select products_id from products where providers_id='".$id."'",$con);
16 if (mysql_num_rows($result)<=0) {
17 $sql = "delete from providers where providers_id='".$id."'";
18 @$result = mysql_query($sql,$con);
19 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
20 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
21 } else {
22 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
23 }
24
25 break;
26 }
27 ?>
28
29 <?
30 if (isset($_POST['ButDel'])) {
31 $cnt=0;
32 foreach ($_POST['chk'] as $id)
33 {
34 @$result = mysql_query("delete from providers where providers_id='".$id."'",$con);
35 if ($result) $cnt++;
36 }
37 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
38 }
39 ?>
40 <?
41 $page = $_GET["page"];
42 $MAXPAGE=10;
43 $p=0;
44 if ($page!='') $p=$page;
45 ?>
46 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
47 <input type="hidden" name="act" value="provider">
48 <input type=hidden name="page" value="<? echo $page; ?>">
49 <?
50 function taotrang($sql,$link,$nitem,$itemcurrent)
51 { global $con;
52 $ret="";
53 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
54 $value = mysql_fetch_array($result);
55 $plus = (($value['cnt'] % $nitem)>0);
56 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
57 {
58 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
59 else $ret .= ($i+1)." ";
60 }
61 return $ret;
62 }
63 $pageindex=taotrang("select count(*) from providers","./?act=provider"."&page=",$MAXPAGE,$page);
64 ?>
65
66 <table cellspacing="0" cellpadding="0">
67 <tr>
68 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
69 </tr>
70 </table>
71
72 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
73 <tr>
74 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
75 <td nowrap class="title"> </td>
76 <td nowrap class="title"> </td>
77 <td align="center" nowrap class="title"><b>Mã</b></td>
78 <td align="center" nowrap class="title"><b>Tên nhà cung cấp</b></td>
79 <td align="center" nowrap class="title"><b>Địa chỉ</b></td>
80 <td align="center" nowrap class="title"><b>Hình</b></td>
81
82 <td align="center" nowrap class="title"><b>Điện thoại</b></td>
83 <td align="center" nowrap class="title"><b>Email</b></td>
84 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
85 <td align="center" nowrap class="title"><b>Ngày</b></td>
86 </tr>
87
88 <?
89 $sql="select *,DATE_FORMAT(providers_dateadded,'%d/%m/%Y %h:%m') as dateformat from providers where providers_status=0 order by providers_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
90 $result=mysql_query($sql,$con);
91 $i=0;
92 while(($row=mysql_fetch_array($result)))
93 {
94 $i++;
95 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
96 ?>
97
98 <tr>
99 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
100 <input type="checkbox" name="chk[]" value="<? echo $row['providers_id']; ?>"></td>
101 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
102 <a href="./?act=provider_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['providers_id']; ?>">
103 Sửa</a></td>
104 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
105 <a href="./?act=provider&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['providers_id']; ?>">
106 Xoá</a></td>
107 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['providers_id']; ?> </td>
108 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_name']; ?> </td>
109 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_address']; ?> </td>
110 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_image']; ?> </td>
111 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_phone']; ?> </td>
112 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_email']; ?> </td>
113 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_status']; ?> </td>
114 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dateformat']; ?> </td>
115 </tr>
116 <?
117 }
118 ?>
119 </table>
120 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
121 </form>
122 <script language="JavaScript">
123 function chkallClick(o) {
124 var form = document.frmList;
125 for (var i = 0; i < form.elements.length; i++) {
126 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
127 form.elements[i].checked = document.frmList.chkall.checked;
128 }
129 }
130 }
131 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Nhà cung cấp : <b> <a href="./?act=provider_m"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> |</font></b></td>
6 </tr>
7 </table>
8 <?
9 $MAXPAGE=20;
10
11 switch ($_GET['action'])
12 {
13 case 'del' :
14 $id = $_GET['id'];
15 $result = mysql_query("select products_id from products where providers_id='".$id."'",$con);
16 if (mysql_num_rows($result)<=0) {
17 $sql = "delete from providers where providers_id='".$id."'";
18 @$result = mysql_query($sql,$con);
19 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
20 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
21 } else {
22 echo "<p align=center class='err'>Đang có sản phẩm sử dụng. nên bạn không thể xóa</p>";
23 }
24
25 break;
26 }
27 ?>
28
29 <?
30 if (isset($_POST['ButDel'])) {
31 $cnt=0;
32 foreach ($_POST['chk'] as $id)
33 {
34 @$result = mysql_query("delete from providers where providers_id='".$id."'",$con);
35 if ($result) $cnt++;
36 }
37 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
38 }
39 ?>
40 <?
41 $page = $_GET["page"];
42 $MAXPAGE=10;
43 $p=0;
44 if ($page!='') $p=$page;
45 ?>
46 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
47 <input type="hidden" name="act" value="provider">
48 <input type=hidden name="page" value="<? echo $page; ?>">
49 <?
50 function taotrang($sql,$link,$nitem,$itemcurrent)
51 { global $con;
52 $ret="";
53 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
54 $value = mysql_fetch_array($result);
55 $plus = (($value['cnt'] % $nitem)>0);
56 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
57 {
58 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
59 else $ret .= ($i+1)." ";
60 }
61 return $ret;
62 }
63 $pageindex=taotrang("select count(*) from providers","./?act=provider"."&page=",$MAXPAGE,$page);
64 ?>
65
66 <table cellspacing="0" cellpadding="0">
67 <tr>
68 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
69 </tr>
70 </table>
71
72 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
73 <tr>
74 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
75 <td nowrap class="title"> </td>
76 <td nowrap class="title"> </td>
77 <td align="center" nowrap class="title"><b>Mã</b></td>
78 <td align="center" nowrap class="title"><b>Tên nhà cung cấp</b></td>
79 <td align="center" nowrap class="title"><b>Địa chỉ</b></td>
80 <td align="center" nowrap class="title"><b>Hình</b></td>
81
82 <td align="center" nowrap class="title"><b>Điện thoại</b></td>
83 <td align="center" nowrap class="title"><b>Email</b></td>
84 <td align="center" nowrap class="title"><b>Không hiển thị</b></td>
85 <td align="center" nowrap class="title"><b>Ngày</b></td>
86 </tr>
87
88 <?
89 $sql="select *,DATE_FORMAT(providers_dateadded,'%d/%m/%Y %h:%m') as dateformat from providers where providers_status=0 order by providers_id limit ".($p*$MAXPAGE).",".$MAXPAGE;
90 $result=mysql_query($sql,$con);
91 $i=0;
92 while(($row=mysql_fetch_array($result)))
93 {
94 $i++;
95 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
96 ?>
97
98 <tr>
99 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
100 <input type="checkbox" name="chk[]" value="<? echo $row['providers_id']; ?>"></td>
101 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
102 <a href="./?act=provider_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['providers_id']; ?>">
103 Sửa</a></td>
104 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
105 <a href="./?act=provider&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['providers_id']; ?>">
106 Xoá</a></td>
107 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['providers_id']; ?> </td>
108 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_name']; ?> </td>
109 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_address']; ?> </td>
110 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_image']; ?> </td>
111 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_phone']; ?> </td>
112 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_email']; ?> </td>
113 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['providers_status']; ?> </td>
114 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dateformat']; ?> </td>
115 </tr>
116 <?
117 }
118 ?>
119 </table>
120 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
121 </form>
122 <script language="JavaScript">
123 function chkallClick(o) {
124 var form = document.frmList;
125 for (var i = 0; i < form.elements.length; i++) {
126 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
127 form.elements[i].checked = document.frmList.chkall.checked;
128 }
129 }
130 }
131 </script>